```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>如何判断链表有环 - 技术小馆</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            line-height: 1.8;
            color: #333;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
        }
        .hero {
            background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
        }
        .code-block {
            background-color: #2d2d2d;
            color: #f8f8f2;
            border-radius: 8px;
            position: relative;
        }
        .code-header {
            background-color: #1e1e1e;
            padding: 8px 16px;
            border-radius: 8px 8px 0 0;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .code-language {
            color: #ccc;
            font-size: 0.9rem;
        }
        .card {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
        }
        .method-icon {
            font-size: 2.5rem;
            margin-bottom: 1rem;
            color: #6e8efb;
        }
        .diagram-container {
            background-color: #f8f9fa;
            border-radius: 8px;
            padding: 20px;
            margin: 20px 0;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl text-center">
            <h1 class="text-4xl md:text-6xl font-bold mb-6 animate-fade-in">如何判断链表有环</h1>
            <p class="text-xl md:text-2xl mb-8 max-w-3xl mx-auto">探索数据结构中环形链表的检测方法与实现原理</p>
            <div class="flex justify-center space-x-4">
                <a href="#methods" class="bg-white text-indigo-600 px-6 py-3 rounded-full font-semibold hover:bg-gray-100 transition duration-300">
                    <i class="fas fa-book-open mr-2"></i>学习方法
                </a>
                <a href="#implementations" class="bg-indigo-700 text-white px-6 py-3 rounded-full font-semibold hover:bg-indigo-800 transition duration-300">
                    <i class="fas fa-code mr-2"></i>查看代码
                </a>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto max-w-5xl px-4 py-12">
        <!-- Introduction -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-md p-8">
                <h2 class="text-3xl font-bold mb-6 text-gray-800">链表环检测的重要性</h2>
                <p class="text-lg text-gray-700 mb-6">
                    当涉及链表问题时，一个关键问题是如何判断链表中是否存在环。链表环的存在可能导致程序陷入无限循环，因此及时检测并处理环是至关重要的。
                </p>
                <div class="diagram-container">
                    <div class="mermaid">
                        graph LR
                            A[头节点] --> B[节点1]
                            B --> C[节点2]
                            C --> D[节点3]
                            D --> E[节点4]
                            E --> C
                    </div>
                </div>
                <p class="text-lg text-gray-700">
                    我将详细介绍这些方法，并探讨它们的优缺点，以及如何从不同角度理解和应用这些方法。通过深入探讨这些方法，我们可以更好地理解链表环的检测机制，为解决链表相关问题提供更多的思路和方法。
                </p>
            </div>
        </section>

        <!-- Methods Section -->
        <section id="methods" class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-center text-gray-800">检测链表环的方法</h2>
            
            <div class="grid md:grid-cols-3 gap-8">
                <!-- Method 1 -->
                <div class="card bg-white rounded-xl p-6">
                    <div class="text-center">
                        <div class="method-icon">
                            <i class="fas fa-running"></i>
                        </div>
                        <h3 class="text-2xl font-bold mb-4 text-gray-800">快慢指针法</h3>
                    </div>
                    <p class="text-gray-700 mb-4">
                        也称为Floyd判圈算法，利用两个指针以不同速度移动来检测环。空间复杂度O(1)，是最优解。
                    </p>
                    <ul class="text-gray-700 mb-4 pl-5 space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>不需要额外空间</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>时间复杂度O(n)</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>可以找到环的入口</span>
                        </li>
                    </ul>
                    <a href="#fast-slow" class="text-indigo-600 font-medium hover:text-indigo-800 transition duration-300">
                        查看详细实现 <i class="fas fa-arrow-right ml-1"></i>
                    </a>
                </div>

                <!-- Method 2 -->
                <div class="card bg-white rounded-xl p-6">
                    <div class="text-center">
                        <div class="method-icon">
                            <i class="fas fa-table"></i>
                        </div>
                        <h3 class="text-2xl font-bold mb-4 text-gray-800">哈希表法</h3>
                    </div>
                    <p class="text-gray-700 mb-4">
                        使用哈希表存储已访问节点，检查是否重复访问。空间复杂度O(n)，实现简单直观。
                    </p>
                    <ul class="text-gray-700 mb-4 pl-5 space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>实现简单</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>时间复杂度O(n)</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                            <span>需要额外空间</span>
                        </li>
                    </ul>
                    <a href="#hash-table" class="text-indigo-600 font-medium hover:text-indigo-800 transition duration-300">
                        查看详细实现 <i class="fas fa-arrow-right ml-1"></i>
                    </a>
                </div>

                <!-- Method 3 -->
                <div class="card bg-white rounded-xl p-6">
                    <div class="text-center">
                        <div class="method-icon">
                            <i class="fas fa-tag"></i>
                        </div>
                        <h3 class="text-2xl font-bold mb-4 text-gray-800">节点标记法</h3>
                    </div>
                    <p class="text-gray-700 mb-4">
                        修改节点结构，添加访问标记。不推荐使用，因为会破坏原始数据结构。
                    </p>
                    <ul class="text-gray-700 mb-4 pl-5 space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>时间复杂度O(n)</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                            <span>修改原始数据</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                            <span>使用场景受限</span>
                        </li>
                    </ul>
                    <a href="#node-marking" class="text-indigo-600 font-medium hover:text-indigo-800 transition duration-300">
                        查看详细实现 <i class="fas fa-arrow-right ml-1"></i>
                    </a>
                </div>
            </div>
        </section>

        <!-- Fast-Slow Pointer Section -->
        <section id="fast-slow" class="mb-16">
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-8">
                    <div class="flex items-center mb-6">
                        <div class="bg-indigo-100 p-3 rounded-full mr-4">
                            <i class="fas fa-running text-indigo-600 text-xl"></i>
                        </div>
                        <h2 class="text-3xl font-bold text-gray-800">快慢指针法</h2>
                    </div>
                    <p class="text-lg text-gray-700 mb-6">
                        判断链表是否有环的常用方法之一是快慢指针法，也称为<strong>Floyd判圈算法</strong>。这种方法利用了两个指针在链表中的移动速度不同的特点来检测链表中是否存在环。
                    </p>
                    
                    <div class="grid md:grid-cols-2 gap-8 mb-8">
                        <div>
                            <h3 class="text-xl font-semibold mb-4 text-gray-800">算法步骤</h3>
                            <ol class="list-decimal pl-5 space-y-3 text-gray-700">
                                <li>定义两个指针，快指针(每次移动两步)和慢指针(每次移动一步)</li>
                                <li>同时从链表起始位置开始移动</li>
                                <li>如果链表有环，快指针会追上慢指针</li>
                                <li>如果快指针到达链表末尾(null)，则无环</li>
                            </ol>
                        </div>
                        <div class="diagram-container">
                            <div class="mermaid">
                                graph LR
                                    A[头节点] --> B[节点1]
                                    B --> C[节点2]
                                    C --> D[节点3]
                                    D --> E[节点4]
                                    E --> C
                                    style A fill:#f8f9fa,stroke:#333
                                    style B fill:#f8f9fa,stroke:#333
                                    style C fill:#f8f9fa,stroke:#333
                                    style D fill:#f8f9fa,stroke:#333
                                    style E fill:#f8f9fa,stroke:#333
                            </div>
                        </div>
                    </div>
                    
                    <div class="mb-8">
                        <h3 class="text-xl font-semibold mb-4 text-gray-800">执行过程可视化</h3>
                        <div class="grid grid-cols-3 gap-4 mb-4">
                            <div class="text-center">
                                <img src="https://cdn.nlark.com/yuque/0/2022/png/21449790/1660735047286-bdb31ff4-cd2b-461f-9da7-2d48509dbf2f.png?x-oss-process=image%2Fresize%2Cw_846%2Climit_0" alt="快慢指针初始状态" class="rounded-lg shadow-sm">
                                <p class="text-sm text-gray-600 mt-2">初始状态</p>
                            </div>
                            <div class="text-center">
                                <img src="https://cdn.nlark.com/yuque/0/2022/png/21449790/1660735062339-ab3f18e5-33e2-4de3-8a48-c22dabbb516d.png" alt="快慢指针移动过程" class="rounded-lg shadow-sm">
                                <p class="text-sm text-gray-600 mt-2">移动过程</p>
                            </div>
                            <div class="text-center">
                                <img src="https://cdn.nlark.com/yuque/0/2022/png/21449790/1660735076773-1635aa4c-c033-439f-a449-96bc9d084843.png?x-oss-process=image%2Fresize%2Cw_881%2Climit_0" alt="快慢指针相遇" class="rounded-lg shadow-sm">
                                <p class="text-sm text-gray-600 mt-2">指针相遇</p>
                            </div>
                        </div>
                    </div>
                    
                    <div class="mb-8">
                        <h3 class="text-xl font-semibold mb-4 text-gray-800">Java实现</h3>
                        <div class="code-block rounded-lg overflow-hidden">
                            <div class="code-header">
                                <span class="code-language">Java</span>
                                <button class="text-gray-400 hover:text-white">
                                    <i class="far fa-copy"></i>
                                </button>
                            </div>
                            <pre class="p-4 overflow-x-auto"><code class="language-java">class ListNode {
    int val;
    ListNode next;
    ListNode(int x) {
        val = x;
        next = null;
    }
}

public class Solution {
    public boolean hasCycle(ListNode head) {
        if (head == null || head.next == null) {
            return false; // 空链表或者只有一个节点的链表不构成环
        }
        
        ListNode slow = head; // 慢指针从链表头部开始移动
        ListNode fast = head.next; // 快指针从链表头部的下一个节点开始移动
        
        // 当快指针追上慢指针时，说明链表中存在环
        while (fast != null && fast.next != null) {
            if (slow == fast) {
                return true;
            }
            slow = slow.next; // 慢指针每次移动一步
            fast = fast.next.next; // 快指针每次移动两步
        }
        
        return false; // 快指针走到了链表尽头，链表中不存在环
    }
}</code></pre>
                        </div>
                    </div>
                    
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-gray-800">如何找到环的入口</h3>
                        <p class="text-gray-700 mb-4">
                            要判断链表是否有环，通常使用快慢指针法。但要找到环的入口节点，则需要额外的步骤。
                        </p>
                        <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1712459674385-5ef06991-cd86-4fc7-bee3-f0045bf275a8.png" alt="环的入口" class="rounded-lg shadow-sm mb-4 w-full">
                        <ol class="list-decimal pl-5 space-y-3 text-gray-700">
                            <li>使用快慢指针确定是否有环</li>
                            <li>确定环的长度</li>
                            <li>让快指针先移动环的长度个节点</li>
                            <li>快慢指针以相同速度移动，相遇点即为环的入口</li>
                        </ol>
                    </div>
                </div>
            </div>
        </section>

        <!-- Hash Table Section -->
        <section id="hash-table" class="mb-16">
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-8">
                    <div class="flex items-center mb-6">
                        <div class="bg-indigo-100 p-3 rounded-full mr-4">
                            <i class="fas fa-table text-indigo-600 text-xl"></i>
                        </div>
                        <h2 class="text-3xl font-bold text-gray-800">哈希表法</h2>
                    </div>
                    <p class="text-lg text-gray-700 mb-6">
                        首先创建一个以节点ID为键的HashSet集合，用来存储曾经遍历过的节点。然后同样是从头节点开始，依次遍历单链表的每一个节点。
                    </p>
                    
                    <div class="grid md:grid-cols-2 gap-8 mb-8">
                        <div>
                            <h3 class="text-xl font-semibold mb-4 text-gray-800">算法步骤</h3>
                            <ol class="list-decimal pl-5 space-y-3 text-gray-700">
                                <li>创建一个哈希表存储已访问节点</li>
                                <li>遍历链表，检查每个节点是否已在哈希表中</li>
                                <li>如果存在，则链表有环</li>
                                <li>如果不存在，将该节点存入哈希表</li>
                                <li>遍历结束未发现重复节点，则无环</li>
                            </ol>
                        </div>
                        <div>
                            <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1712459527976-bd5c284a-29ee-4562-bcae-a8183c31c57c.png" alt="哈希表法" class="rounded-lg shadow-sm w-full">
                        </div>
                    </div>
                    
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-gray-800">Java实现</h3>
                        <div class="code-block rounded-lg overflow-hidden">
                            <div class="code-header">
                                <span class="code-language">Java</span>
                                <button class="text-gray-400 hover:text-white">
                                    <i class="far fa-copy"></i>
                                </button>
                            </div>
                            <pre class="p-4 overflow-x-auto"><code class="language-java">import java.util.HashMap;
import java.util.Map;

class ListNode {
    int val;
    ListNode next;
    ListNode(int x) {
        val = x;
        next = null;
    }
}

public class Solution {
    public boolean hasCycle(ListNode head) {
        if (head == null || head.next == null) {
            return false; // 空链表或者只有一个节点的链表不构成环
        }
        
        Map<ListNode, Boolean> visited = new HashMap<>();
        ListNode current = head;
        
        // 遍历链表，并将每个节点加入到哈希表中
        while (current != null) {
            // 如果当前节点已经在哈希表中存在，则说明链表中存在环
            if (visited.containsKey(current)) {
                return true;
            }
            // 否则将当前节点加入到哈希表中
            visited.put(current, true);
            // 继续遍历下一个节点
            current = current.next;
        }
        
        return false; // 遍历完整个链表都没有找到相同的节点，说明链表中不存在环
    }
}</code></pre>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Node Marking Section -->
        <section id="node-marking" class="mb-16">
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-8">
                    <div class="flex items-center mb-6">
                        <div class="bg-indigo-100 p-3 rounded-full mr-4">
                            <i class="fas fa-tag text-indigo-600 text-xl"></i>
                        </div>
                        <h2 class="text-3xl font-bold text-gray-800">节点标记法</h2>
                    </div>
                    <p class="text-lg text-gray-700 mb-6">
                        可以在每个节点上添加一个标记，表示该节点是否被访问过。如果再次访问到已经被标记的节点，则说明链表有环。这种方法需要修改原始链表的结构，不太推荐。
                    </p>
                    
                    <div class="grid md:grid-cols-2 gap-8 mb-8">
                        <div>
                            <h3 class="text-xl font-semibold mb-4 text-gray-800">算法步骤</h3>
                            <ol class="list-decimal pl-5 space-y-3 text-gray-700">
                                <li>遍历链表，访问每个节点</li>
                                <li>检查节点是否已被标记</li>
                                <li>如果已被标记，则链表有环</li>
                                <li>否则，标记该节点为已访问</li>
                                <li>遍历结束未发现标记节点，则无环</li>
                            </ol>
                        </div>
                        <div>
                            <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1712459828007-3676939b-e8d4-443a-8293-1ef9dd0d13bb.png" alt="节点标记法" class="rounded-lg shadow-sm w-full">
                        </div>
                    </div>
                    
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-gray-800">Java实现</h3>
                        <div class="code-block rounded-lg overflow-hidden">
                            <div class="code-header">
                                <span class="code-language">Java</span>
                                <button class="text-gray-400 hover:text-white">
                                    <i class="far fa-copy"></i>
                                </button>
                            </div>
                            <pre class="p-4 overflow-x-auto"><code class="language-java">class ListNode {
    int val;
    ListNode next;
    ListNode(int x) {
        val = x;
        next = null;
    }
}

public class Solution {
    public boolean hasCycle(ListNode head) {
        if (head == null || head.next == null) {
            return false; // 空链表或者只有一个节点的链表不构成环
        }
        
        ListNode current = head;
        
        // 遍历链表，并修改每个节点的标记
        while (current != null) {
            // 如果当前节点的标记为已访问，说明链表中存在环
            if (current.val == Integer.MIN_VALUE) {
                return true;
            }
            // 否则将当前节点标记为已访问
            current.val = Integer.MIN_VALUE;
            // 继续遍历下一个节点
            current = current.next;
        }
        
        return false; // 遍历完整个链表都没有找到已被标记的节点，说明链表中不存在环
    }
}</code></pre>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Comparison Section -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-md p-8">
                <h2 class="text-3xl font-bold mb-8 text-center text-gray-800">方法比较</h2>
                
                <div class="overflow-x-auto">
                    <table class="min-w-full divide-y divide-gray-200">
                        <thead class="bg-gray-50">
                            <tr>
                                <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">方法</th>
                                <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">时间复杂度</th>
                                <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">空间复杂度</th>
                                <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">是否修改原链表</th>
                                <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">适用场景</th>
                            </tr>
                        </thead>
                        <tbody class="bg-white divide-y divide-gray-200">
                            <tr>
                                <td class="px-6 py-4 whitespace-nowrap font-medium text-gray-900">快慢指针法</td>
                                <td class="px-6 py-4 whitespace-nowrap text-gray-500">O(n)</td>
                                <td class="px-6 py-4 whitespace-nowrap text-gray-500">O(1)</td>
                                <td class="px-6 py-4 whitespace-nowrap text-gray-500">否</td>
                                <td class="px-6 py-4 whitespace-nowrap text-gray-500">最优解，推荐使用</td>
                            </tr>
                            <tr>
                                <td class="px-6 py-4 whitespace-nowrap font-medium text-gray-900">哈希表法</td>
                                <td class="px-6 py-4 whitespace-nowrap text-gray-500">O(n)</td>
                                <td class="px-6 py-4 whitespace-nowrap text-gray-500">O(n)</td>
                                <td class="px-6 py-4 whitespace-nowrap text-gray-500">否</td>
                                <td class="px-6 py-4 whitespace-nowrap text-gray-500">简单直观，需要额外空间</td>
                            </tr>
                            <tr>
                                <td class="px-6 py-4 whitespace-nowrap font-medium text-gray-900">节点标记法</td>
                                <td class="px-6 py-4 whitespace-nowrap text-gray-500">O(n)</td>
                                <td class="px-6 py-4 whitespace-nowrap text-gray-500">O(1)</td>
                                <td class="px-6 py-4 whitespace-nowrap text-gray-500">是</td>
                                <td class="px-6 py-4 whitespace-nowrap text-gray-500">不推荐，会修改原链表</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </section>

        <!-- Summary Section -->
        <section class="mb-16">
            <div class="bg-indigo-50 rounded-xl shadow-md p-8">
                <h2 class="text-3xl font-bold mb-6 text-center text-indigo-800">总结与建议</h2>
                <div class="grid md:grid-cols-2 gap-8">
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-indigo-700">最佳实践</h3>
                        <ul class="space-y-3 text-gray-700">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-600 mt-1 mr-3"></i>
                                <span>优先使用<strong>快慢指针法</strong>，空间复杂度最优</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-600 mt-1 mr-3"></i>
                                <span>在需要简单实现且不介意额外空间时，可以使用<strong>哈希表法</strong></span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-600 mt-1 mr-3"></i>
                                <span>尽量避免使用<strong>节点标记法</strong>，除非明确可以修改链表结构</span>
                            </li>
                        </ul>
                    </div>
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-indigo-700">扩展思考</h3>
                        <ul class="space-y-3 text-gray-700">
                            <li class="flex items-start">
                                <i class="fas fa-lightbulb text-indigo-600 mt-1 mr-3"></i>
                                <span>如何计算环的长度？</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-lightbulb text-indigo-600 mt-1 mr-3"></i>
                                <span>如何找到环的入口节点？</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-lightbulb text-indigo-600 mt-1 mr-3"></i>
                                <span>如何将带环链表转换为无环链表？</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-12">
        <div class="container mx-auto px-4 text-center">
            <h3 class="text-2xl font-bold mb-4">技术小馆</h3>
            <p class="mb-6">探索计算机科学的奥秘，分享编程技术的精髓</p>
            <div class="flex justify-center space-x-4 mb-6">
                <a href="http://www.yuque.com/jtostring" class="hover:text-indigo-400 transition duration-300">
                    <i class="fas fa-globe text-xl"></i>
                </a>
            </div>
            <p class="text-gray-400 text-sm">
                &copy; 2023 技术小馆. 保留所有权利.
                <br>
                <a href="http://www.yuque.com/jtostring" class="text-indigo-400 hover:text-indigo-300">http://www.yuque.com/jtostring</a>
            </p>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
        
        // 复制代码功能
        document.querySelectorAll('.code-header button').forEach(button => {
            button.addEventListener('click', () => {
                const codeBlock = button.parentElement.nextElementSibling;
                const code = codeBlock.textContent;
                navigator.clipboard.writeText(code).then(() => {
                    button.innerHTML = '<i class="fas fa-check"></i>';
                    setTimeout(() => {
                        button.innerHTML = '<i class="far fa-copy"></i>';
                    }, 2000);
                });
            });
        });
    </script>
</body>
</html>
```